package drawer

import (
	"MetroBuilderGameJam/gameEngine/geom"
	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/vector"
	"image/color"
)

func (d *Drawer) BorderedCircle(dst *ebiten.Image, pos geom.Point, radius, w float64, clr color.Color, bg color.Color) {
	offset := d.applyAnchor(d.Offset.AsVec2().Add(pos.AsVec2()), geom.Size{radius, radius})
	vector.DrawFilledCircle(dst, float32(offset.X), float32(offset.Y), float32(radius), bg, false)
	vector.StrokeCircle(dst, float32(offset.X), float32(offset.Y), float32(radius), float32(w), clr, false)
	d.drawPivot(dst, pos, clr)
}

func (d *Drawer) BorderedSquare(dst *ebiten.Image, pos geom.Point, size, w float64, clr color.Color, bg color.Color) {
	d.BorderedRectangle(dst, pos, geom.Size{Width: size, Height: size}, w, clr, bg)
}

func (d *Drawer) BorderedRectangle(dst *ebiten.Image, pos geom.Point, size geom.Size, w float64, clr color.Color, bg color.Color) {
	d.FillRectangle(dst, pos, size, 0, bg)
	d.Rectangle(dst, pos, size, w, 0, clr)
}

func (d *Drawer) BorderedSimpleRectangle(dst *ebiten.Image, pos geom.Point, size geom.Size, w float64, clr color.Color, bg color.Color) {
	d.FillSimpleRectangle(dst, pos, size, bg)
	d.SimpleRectangle(dst, pos, size, w, clr)
}

func (d *Drawer) BorderedSimpleTriangle(dst *ebiten.Image, pos geom.Point, size, w float64, clr color.Color, bg color.Color) {
	path := d.GetPathForSimpleTriangle(pos, size, 0)

	vs, is, op := d.preparePathToFill(path, bg)
	d.drawPath(dst, vs, is, op)

	vs, is, op = d.preparePathToDraw(path, w, clr)
	d.drawPath(dst, vs, is, op)

	d.drawPivot(dst, pos, clr)
}

func (d *Drawer) BorderedPentagon(dst *ebiten.Image, pos geom.Point, size, w float64, clr color.Color, bg color.Color) {
	path := d.GetPathForPentagon(pos, size, 0)

	vs, is, op := d.preparePathToFill(path, bg)
	d.drawPath(dst, vs, is, op)

	vs, is, op = d.preparePathToDraw(path, w, clr)
	d.drawPath(dst, vs, is, op)

	d.drawPivot(dst, pos, clr)
}

func (d *Drawer) BorderedStar(dst *ebiten.Image, pos geom.Point, size, w float64, clr color.Color, bg color.Color) {
	path := d.GetPathForStar(pos, size, 0)

	vs, is, op := d.preparePathToFill(path, bg)
	d.drawPath(dst, vs, is, op)

	vs, is, op = d.preparePathToDraw(path, w, clr)
	d.drawPath(dst, vs, is, op)

	d.drawPivot(dst, pos, clr)
}

func (d *Drawer) BorderedCross(dst *ebiten.Image, pos geom.Point, size, w float64, clr color.Color, bg color.Color) {
	path := d.GetPathForStar(pos, size, 0)

	vs, is, op := d.preparePathToFill(path, bg)
	d.drawPath(dst, vs, is, op)

	vs, is, op = d.preparePathToDraw(path, w, clr)
	d.drawPath(dst, vs, is, op)

	d.drawPivot(dst, pos, clr)
}
